<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<title>供需对接服务系统--我的项目</title>
	<!--公用样式-->
	<link rel="stylesheet" type="text/css" href="${re.contextPath}/plugin/common/css/comment.css"/>
	<link rel="stylesheet" type="text/css" href="${re.contextPath}/plugin/supplier/common/css/style.css"/>
	<!--Layui-->
	<link rel="stylesheet" href="${re.contextPath}/plugin/layui/css/layui.css" media="all"/>
	<!--extended-->
	<link rel="stylesheet" type="text/css" href="${re.contextPath}/plugin/common/css/extended.css"/>
	<!--公用样式JS-->
	<script type="text/javascript" src="${re.contextPath}/plugin/jquery/jquery-3.2.1.min.js"></script>
	<script type="text/javascript" charset="utf-8" src="${re.contextPath}/plugin/common/js/comment.js"></script>
	<script type="text/javascript" src="${re.contextPath}/plugin/layui/layui.js" charset="utf-8"></script>
</head>
<style>
	.Right {
		width: 100%;
		overflow-y: scroll;
	}

</style>

<body>
<!--头部-->

<!--容器-->
<div class="container clearfix">
	<!--右侧内容-->
	<div class="Right fr mt10">
		<div class="screening screeningOne whitebg clearfix">
			<ul class="clearfix fl"  style="width: 85%;">
				<li  style="width: 15%;">
					<div>项目类型</div>
					<select name="projectType" id="projectType">
						<option value="">全部</option>
						<#list projectTypeList as vo>
						  <option value="${vo.badtCode}">${vo.badtName}</option>
						</#list>
					</select>
				</li>
				<li style="width: 15%;">
					<div>项目状态</div>
					<select name="status"  style="width: 100%;" id="status">
						<option value="">全部</option>
						<option value="001">已保存</option>
						<option value="002">待审核</option>
						<option value="003">已驳回</option>
						<option value="004">已结束</option>
						<option value="005">已撤销</option>
						<option value="006">已发布</option>
					</select>
				</li>
				<li style="width: 15%; margin-left: 28px;">
					<div>中标状态</div>
					<select name="zbStatus"  style="width: 100%;" id="zbStatus">
						<option value="">全部</option>
						<option value="1">已中标</option>
						<option value="0">未中标</option>
					</select>
				</li>
				<li style="margin-left: 28px;width: 33%;">
					<div>项目名称</div>
					<input  type="hidden"  value="${gxtype}"  id="gxtype"/>
					<input type="text" name="projectName" id="projectName" placeholder="请输入项目名称" style="width: 90%;" autocomplete="off">
				</li>
			</ul>
			<div class="fl mt30">
				<button type="button" class="bluebg white"  style="width: 120px;" onclick="query()">筛选</button>
			</div>
		</div>

		<div class="project whitebg">
			 <table id="tableList" class="layui-hide" lay-filter="tableList"></table>
		</div>
	</div>
</div>
<script type="text/javascript" src="${re.contextPath}/plugin/tools/tool.js"></script>
<script type="text/javascript" charset="utf-8" src="${re.contextPath}/plugin/common/js/tabs.js"></script>
<script type="text/javascript">
	<#assign currentUser = Session["currentPrincipal"]>
	var layer;
	var form = layui.form;
	var table = null;
	var tableIns = null;
	//注意进度条依赖 element 模块，否则无法进行正常渲染和功能性操作
	var element = "";
	layui.use('element', function () {
		element = layui.element;
	});
	layui.use('laydate', function () {
		var laydate = layui.laydate;
		//执行一个laydate实例
		laydate.render({
			elem: '#beginDate' //指定元素
		});
		laydate.render({
			elem: '#endDate' //指定元素
		});
	});



	function query() {
		var projectName = $('#projectName').val();
		var projectType= $("#projectType").find("option:selected").attr("value");
		var status= $("#status").find("option:selected").attr("value");
		var zbStatus= $("#zbStatus").find("option:selected").attr("value");
		var jsondata = {
			projectName:projectName,
			projectType:projectType,
			status:status,
			zbStatus:zbStatus
		};

		table.reload('tableList', {where: jsondata});
	}

	layui.use('table', function () {
		table = layui.table;
		element = element;
		//方法级渲染
		var  gxtype="${gxtype}";
		var isshow=true;
		if(gxtype=="x"){
			isshow=false;
		}
		var operr="20%";
		var iszbshow=true;
		if(gxtype=="g"){
			iszbshow=false;
			operr="25%";
		}

		tableIns = table.render({
			id: 'tableList',
			elem: '#tableList',
			url: '/supplier/projectManager/myProjectList',
			height: "auto",
			page: true,
			cols: [[
				{
					title: '序号', width: '10%',align:'center', templet: function (res) {
						return res.LAY_INDEX;
					}
				},
				{field: 'supProjectId', title: 'supProjectId',align:'center', width: '10%', hide:true,sort: true},
				{field: 'projectType', title: '项目类型', align:'center',width: '10%', sort: true,templet: function (d) {
					var typestr=[];
					var type=d.projectType;
					if(type){
						if (type.indexOf("001")>-1) {
							typestr.push("监理");
						}
						if (type.indexOf("002")>-1) {
							typestr.push("咨询");
						}
						if (type.indexOf("003")>-1) {
							typestr.push("检测");
						}
						if (type.indexOf("100")>-1) {
							typestr.push("其他");
						}
						typestr=typestr.join(",");
					}
					return  typestr;


		        }},
				{field: 'projectName', title: '项目名称', align:'center',width: '20%', sort: true,templet:function (d) {
						return '<span  style="color: blue;" class="cursor" onclick="showDetail(\'' + d.supProjectId + '\',\'' + d.projectName + '\')">' + d.projectName + '</span>';
					}},
				{field: 'status', title: '项目状态',align:'center', width: '10%', sort: true,templet: function (d) {
						if (d.status == "001") {
							return '<span class="status1" >已保存</span>';
						}
						if (d.status == "002") {
							return '<span class="status5" >待审核</span>';
						}
						if (d.status == "003") {
							return '<span class="status" >已驳回</span>';
						}
						if (d.status == "004") {
							return '<span class="status4">已结束</span>';
						}
						if (d.status == "005") {
							return '<span class="status2" >已撤销</span>';
						}
						if (d.status == "006") {
							return '<span  class="status3" >已发布</span>'
						}
					}},
				{field: 'createDate', title: '发布时间', align:'center',width: '15%', sort: true},
				{field: 'isGs', title: '是否公示', align:'center',width: '20%', hide:true,sort: true},
				{field: 'zbBy', title: '中标人',align:'center', width: '20%',hide:true,sort: true},
				{field: 'zbStatus', title: '是否中标',align:'center', width: '20%',hide:true, sort: true},
				{field: 'zbPersonName', title: '发布时间', align:'center',width: '20%', hide:true,sort: true},
				{field: 'zbPersonNameLink', title: '发布时间', align:'center',width: '15%',hide:true,sort: true},
				{field: 'oper', title: '操作', width: operr, align:'center',sort: true,templet: function (d) {
						var  gxtype="${gxtype}";
						var   str="";
						if(gxtype=="x" && d.isGs!="1"  && d.zbStatus=='1' ){
							str=str+'<span class="cursor"  style="color: blue;" onclick="pushjggs(\'' + d.supProjectId + '\')" >发布结果公示</span>&nbsp;';
						}
						if(d.isGs=="1" && d.zbStatus=='1' ){
							str=str+'<span  class="cursor" style="color: blue;" onclick="viewjggs(\'' + d.supProjectId + '\')" >查看结果公示</span>&nbsp;';
						}
						if(gxtype=="g" &&  d.status=="006"){
							str=str+'<span  class="cursor" style="color: blue;" onclick="cxAccept(\'' + d.supProjectId + '\')" >撤销应接</span>&nbsp;';
						}
						if( d.status=="006"  ||  d.status=="004"  ){
							str=str+'<span  class="cursor" style="color: blue;" onclick="viewChangeClick(\'' + d.supProjectId + '\')" >查看变更</span>&nbsp;';
						}
						if('${currentUser.id}'==d.zbBy){
							str=str+'<span class="cursor" style="color: blue;" onclick="viewUserDetail(\'' + d.supProjectId + '\')" >查看系统账号</span>&nbsp;';
						}
                         return str;
					}},
				{field: 'companyName', title: '中标单位(中标人)', width: '15%',align:'center', sort: true,hide:isshow,templet: function (d) {
					if(d.companyName!=null  && d.companyName!=""  ){
						var str="";
						if(d.zbPersonName!=null  && d.zbPersonName!=""){
							 str=d.companyName+"("+d.zbPersonName+")";
						}else{
							str=d.companyName+"("+d.zbPersonNameLink+")";
						}
						return   '<span  >'+str+'</span>'
					}else{
						return   ''
					}
		        }},
				{field: 'companyName', title: '是否中标', width: '10%', align:'center', sort: true,hide:iszbshow,templet: function (d) {
						if('${currentUser.id}'==d.zbBy){
							return   '<span> <img src=\"${re.contextPath}/plugin/common/images/73@2x.png\" class=\"ml20\"/></span>';
						}else{
							return   '';
						}
					}}
			]],
			done: function (res, currentCount) {
				//***重点***：table渲染完成后渲染element进度条
				element.render();
				$(".layui-table-page select").css("width","80px");

			}
		});
		//监听工具条
		table.on('tool(tableList)', function (obj) {
			var data = obj.data;
			var that = $(this);
			if(obj.event === 'resetPassword') {
				parent.layer.confirm('确定重置密码？', function (index) {
					var userId=data.userId;
					layerAjax("resetPassword", {id: userId}, "", function (d) {
						if (d.flag) {
							parent.layer.close(index);
							layer.msg("操作成功", {icon: 1});
							tableIns.reload();
						} else {
							layer.msg("操作失败", {icon: 2});
						}
					})
				});
			}
		});
	});
	function showDetail(id, projectName) {
		window.parent._showtab('xm_v' + id, '查看-' +projectName, '/supplier/projectManager/projectDetail?type=v&supProjectId=' +id);
	}
	function provinceChange(object){
		var code = $(object).find('option:selected').val();
		if (code == "") {
			return;
		}
		layerAjaxGet('/sys/register/getOrganize', {"code": code}, '', function (d) {
			if (d.flag == true) {
				$(object).next().empty().append("<option value=''>选择市</option>");
				for (var i = 0; i < d.data.length; i++) {
					$(object).next().append("<option value='" + d.data[i].code + "'>" + d.data[i].name + "</option>");
				}
			} else {
				layer.msg(d.msg, {icon: 2});
			}
		});


	};
	function cityChange (object){
		var code = $(object).find('option:selected').val();
		if (code == "") {
			return;
		}
		layerAjaxGet('/sys/register/getOrganize', {"code": code}, '', function (d) {
			if (d.flag == true) {
				$(object).next().empty().append("<option value=''>选择区县</option>");
				for (var i = 0; i < d.data.length; i++) {
					$(object).next().append("<option value='" + d.data[i].code + "'>" + d.data[i].name + "</option>");
				}
			} else {
				layer.msg(d.msg, {icon: 2});
			}
		});


	}

	 // 查看账号
	function viewUserDetail (supProjectId){
		var title = "系统账号";
		var url = "/supplier/viewUserDetail?supProjectId=" + supProjectId;
		var w = "800px";
		var h = "60%";
		layer.open({
			id: 'form-add',
			type: 2,
			area: [w, h],
			fix: false,
			maxmin: true,
			shadeClose: false,
			shade: 0.4,
			title: title,
			content: url,
			end: function () {

			}
		});


	}
	function viewjggs (supProjectId){
		//打开文件列表
		var title = "结果公示";
		var url = "/supplier/gspubnotice/viewPushGsDetail?supProjectId=" + supProjectId;
		var w = "500px";
		var h = "60%";
		layer.open({
			id: 'form-add',
			type: 2,
			area: [w, h],
			fix: false,
			maxmin: true,
			shadeClose: false,
			shade: 0.4,
			title: title,
			content: url,
			end: function () {

			}
		});




	}
	//  撤销应接
	function  cxAccept(supProjectId){
		// 撤销应接
		layer.confirm('确定撤销应接吗？', {
			btn: ['确定', '取消'],

		}, function (index) {
			layerAjax('/supplier/projectManager/updateCxAccept', {
				"supProjectId": supProjectId
			}, '', function (d) {
				if (d.flag) {
					layer.msg("操作成功！");
					table.reload('tableList', {where: {}});

				} else {
					layer.msg(d.msg, {icon: 2});
				}
			});

		}, function (index) {

		});

	}

	function viewChangeClick (supProjectId) {
		layerAjaxGet('/supplier/projectManager/queryChangeCount', {
			"supProjectId": supProjectId
		}, '', function (d) {
			if (d.flag) {
				var type = "auto";
				var w = "100%";
				var h = "100%";
				var url="/supplier/projectManager/viewChangeDetail?supProjectId="+supProjectId;
				layer.open({
					id: 'form-add',
					type: 2,
					area: [w, h],
					fix: false,
					maxmin: true,
					shadeClose: false,
					shade: 0.4,
					title: "变更公告",
					content: url,
					end: function () {

					}
				});
			} else {
				layer.msg(d.msg, {icon: 2});
			}
		});


	}

	function pushjggs (supProjectId){

		//打开文件列表
		var title = "结果公示";
		var url = "/supplier/gspubnotice/pushGsDetail?supProjectId=" + supProjectId;
		var w = "500px";
		var h = "400px";
		layer.open({
			id: 'form-add',
			type: 2,
			area: [w, h],
			fix: false,
			maxmin: true,
			shadeClose: false,
			shade: 0.4,
			title: title,
			content: url,
			end: function () {
				table.reload('tableList', {where: {}});
			}
		});





	}




</script>
</body>

</html>
